module IncidentsHelper
  def incidents_index_fields(options)
    %w[id category_name title num_rpts status place_name last_updated actions]
  end
  
  def incidents_format_field(obj, field, options)
    case field
    when "id"
      "#" + obj.id.to_s.rjust(3, "0")
    when "last_updated"
      distance_of_time_in_words(obj.updated_at, Time.now) + " ago"
    when "nothing"
    when "actions"
      if options[:mode] == :choose
        link_to("choose", choose_incident_url(obj, :report_id => options[:report_id]))
      else
        action_links(obj, :destroy_warning => "Are you sure you want to delete incident '#{obj.title}'", :exclude => [:show])
      end
    else
      obj.send(field)
    end
  end
  
  def incidents_index_links(objs, options)
    []
  end
end
